package com.googlecode.nacl_optimizer.tests;

import junit.framework.Assert;

import org.junit.Test;

import com.googlecode.nacl_optimizer.elf.StdoutParser;


public class ExtractArgsTests
{
    @Test
    public void extract_args_1()
    {
        Assert.assertEquals(
                "",
                StdoutParser.extract_arguments( "   20007:\t90                   \tnop", "nop" ));
    }
    
    @Test
    public void extract_args_2() 
    {
        Assert.assertEquals(
                "$0xfffffff0,%esp",
                StdoutParser.extract_arguments( "   2008f:\t83 e4 f0             \tand    $0xfffffff0,%esp", "and   ")
                );
    }
    
    @Test
    public void extract_args_3() //
    {
        Assert.assertEquals(
                "0x0(%edi,%eiz,1),%edi",
                StdoutParser.extract_arguments( "   24359:\t8d bc 27 00 00 00 00 \tlea    0x0(%edi,%eiz,1),%edi", "lea   "));
    }
    
    @Test
    public void extract_args_4()
    {
        Assert.assertEquals(
                "201e0 <__do_global_dtors_aux>",
                StdoutParser.extract_arguments( "   34c9b:\te8 40 b5 fe ff       \tcall   201e0 <__do_global_dtors_aux>", "call  "));
    }
    
    @Test
    public void extract_args_5()
    {
        Assert.assertEquals(
                "",
                StdoutParser.extract_arguments( "   2460a:\tff ff ff ", "nop"));
    }
    
    @Test
    public void extract_args_6()
    {
        Assert.assertEquals(
                "",
                StdoutParser.extract_arguments( "   248ce:\t00 ", "nop"));
    }
    
    @Test
    public void extract_args_7()
    {
        Assert.assertEquals(
                "",
                StdoutParser.extract_arguments( "   34cbf:\tf4                   \thlt    ", "hlt   "));
    }
    
    @Test
    public void extract_args_8()
    {
        Assert.assertEquals(
                "0x1(%eax),%eax",
                StdoutParser.extract_arguments( "   29d33:\t0f b6 40 01          \tmovzbl 0x1(%eax),%eax", "movzbl"));
    }

}
